//
//  MYGMeetingDetailTableViewCell.swift
//  MYDoctor
//
//  Created by 王振明 on 2024/5/11.
//

import UIKit

class MYGMeetingDetailTableViewCell: UITableViewCell {
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        configUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    var model:MYGMeetingRoomListModel = MYGMeetingRoomListModel(){
        didSet{
            if model.roomStartTime.count > 0{
                let startIndex = model.roomStartTime.index(model.roomStartTime.startIndex, offsetBy: 5)
                let endIndex = model.roomStartTime.index(model.roomStartTime.startIndex, offsetBy: 10)
                dateLabel.text = String(model.roomStartTime[startIndex..<endIndex])
            }
            titleLab.text = model.sessionCn
            timeLabel.text = "时间: \(model.roomStartTime) - \(model.roomEndTime)"
            huichangLabel.text = "讲题: \(model.speechCn)"
            adressLabel.text = "会场: \(model.roomCn)"
            taskLabel.text = "任务: \(model.expertRoleCn)"
        }
    }
    private func configUI(){
        contentView.backgroundColor = .clear
        self.backgroundColor = .clear
        
        contentView.addSubview(whitebackView)
        whitebackView.snp.makeConstraints { make in
            make.left.top.equalToSuperview().offset(20)
            make.height.equalTo(174)
            make.right.equalToSuperview().offset(-20)
        }
        
        whitebackView.addSubview(colorView)
        colorView.snp.makeConstraints { make in
            make.left.top.right.equalToSuperview()
            make.height.equalTo(31.5)
        }
        
        whitebackView.addSubview(dateLabel)
        dateLabel.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(17.5)
            make.top.equalToSuperview().offset(5.5)
            make.height.equalTo(20)
        }

        whitebackView.addSubview(allBtn)
        allBtn.snp.makeConstraints { make in
            make.right.equalToSuperview().offset(-17.5)
            make.centerY.equalTo(dateLabel)
            make.height.equalTo(20)
        }
        whitebackView.addSubview(titleLab)
        titleLab.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(17.5)
            make.top.equalTo(colorView.snp.bottom).offset(12.5)
            make.height.equalTo(22.5)
        }
        whitebackView.addSubview(timeLabel)
        timeLabel.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(17.5)
            make.top.equalTo(titleLab.snp.bottom).offset(7.5)
            make.height.equalTo(15)
        }
        whitebackView.addSubview(huichangLabel)
        huichangLabel.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(17.5)
            make.top.equalTo(timeLabel.snp.bottom).offset(7.5)
            make.height.equalTo(15)
        }
        whitebackView.addSubview(adressLabel)
        adressLabel.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(17.5)
            make.top.equalTo(huichangLabel.snp.bottom).offset(7.5)
            make.height.equalTo(15)
        }
        whitebackView.addSubview(taskLabel)
        taskLabel.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(17.5)
            make.top.equalTo(adressLabel.snp.bottom).offset(7.5)
            make.height.equalTo(15)
        }
    }
    private lazy var whitebackView:UIView = {
       let cont = UIView()
        cont.backgroundColor = .white
        cont.layer.cornerRadius = 4
        cont.clipsToBounds = true
        cont.layerShadowColor = .rgba(233, 231, 241, 1)
        cont.layerShadowOffset = CGSize(width: 0, height: 2.5)
        cont.layerShadowOpacity = 1
        cont.layerShadowRadius = 7.5
        return cont
    }()
    private lazy var dateLabel: UILabel = {
        let label = UILabel()
        label.textColor = .rgba(255, 112, 82, 1)
        label.font = .medium(13)
        label.textAlignment = .center
        return label
    }()
    private lazy var colorView: UIView = {
        let vi = UIView()
        vi.backgroundColor = .rgba(255, 112, 82, 0.08)
        return vi
    }()
    private lazy var titleLab: UILabel = {
        let label = UILabel()
        label.textColor = .rgba(18, 18, 18, 1)
        label.font = .medium(16)
        return label
    }()
    private lazy var timeLabel: UILabel = {
        let label = UILabel()
        label.textColor = .rgba(69, 70, 77, 1)
        label.font = .regular(11)
        return label
    }()
    private lazy var huichangLabel: UILabel = {
        let label = UILabel()
        label.textColor = .rgba(69, 70, 77, 1)
        label.font = .regular(11)
        return label
    }()
    private lazy var adressLabel: UILabel = {
        let label = UILabel()
        label.textColor = .rgba(69, 70, 77, 1)
        label.font = .regular(11)
        return label
    }()
    private lazy var taskLabel: UILabel = {
        let label = UILabel()
        label.textColor = .rgba(69, 70, 77, 1)
        label.font = .regular(11)
        return label
    }()
    private lazy var allBtn: UIButton = {
        let label = UIButton()
        label.setTitleColor(.rgba(255, 112, 82, 1), for: .normal)
        label.titleLabel?.font = .medium(11)
        label.setTitle("查看全部", for: .normal)
        return label
    }()
}
